package com.up.interview.controller;

import com.up.interview.exception.EnableAutoTryCatch;
import com.up.interview.redis.RedisHashCacheManager;
import com.up.interview.redis.redisson.LockManger;
import com.up.interview.redis.redisson.LockRequest;
import com.up.interview.redis.redisson.ReturnCallBack;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author: liuchengjun
 * @title: RedisTestController
 * @projectName: 海联技术中台V2.0
 * @depart 软件事业部
 * @description:
 * @date: 2025/10/20/周一 15:25 (星期一)
 * @since V2.0
 */
@RestController
@EnableAutoTryCatch
public class RedisTestController {
    @Autowired
    private RedisHashCacheManager redisHashCacheManager;
    @Autowired
    private LockManger lockManger;

    @GetMapping("/get")
    public Object get(@RequestParam String id, @RequestParam String key) {
        return redisHashCacheManager.get(id, key);

    }

    @GetMapping("/add")
    public Object add(@RequestParam String id, @RequestParam String key,String value) {
        redisHashCacheManager.put(id, key,value);
        return "success";

    }

    @DeleteMapping("/del")
    public Object del(@RequestParam String id, @RequestParam String key) {
        redisHashCacheManager.del(id, key);
        return "del success";

    }

    @GetMapping("/test")
    public Object test() {
        lockManger.test();
        return " success";

    }


    @GetMapping("/testExce")
    public Object testExce() {
        int i = 1/0;
        return " success";

    }
}
